﻿@model HxBlogs.Model.Blog
@{
    ViewBag.Title = Model.Title;
}
@section styles{
    @Styles.Render("~/content/default")
    @Styles.Render("~/content/default")
    <link href="~/Plugins/editormd/css/editormd.preview.css" rel="stylesheet" />
}
<div class="hx-container blog-view">
    <div class="d-flex">
        @{ 
            Html.RenderPartial("side", ViewBag.User as HxBlogs.Model.UserInfo);
        }
        <div class="flex-fill flex-column mt-2 ml-2 py-3 px-4 bg-white">
            <div class="mt-2">
                <div>
                    <h4>@Model.Title</h4>
                </div>
                <div class="d-flex flex-wrap align-content-start">
                    <span class="hx-text">@(UserContext.GetDisplayName(Model.User)+ (Model.IsPublish? "发布于":"")) </span>
                    <span class="hx-text mr-2">@WebHelper.GetDispayDate(Model.PublishDate, true)</span>
                    <span class="hx-text mr-2">阅读数:@Model.ReadCount</span>
                    <span class="hx-text mr-2">收藏:@Model.FavCount</span>
                    <span class="hx-text mr-2">点赞:@Model.LikeCount</span>
                    <div class="hx-text mr-2 blog-tag">
                        个人分类：
                        @if (ViewBag.BlogTag != null)
                        {
                            foreach (HxBlogs.Model.BlogTag tag in ViewBag.BlogTag)
                            {
                                <a target="_blank" href="@WebHelper.GetFullUrl("/article/" + tag.UserName + "/tag/" + tag.HexId)">@tag.Name</a>
                            }
                        }
                    </div>
                </div>
            </div>
            <div class="mt-4 blog-content">
                @(new HtmlString(Model.ContentHtml))
                @*<textarea style="display:none;" placeholder="markdown语言"></textarea>*@
            </div>
        </div>
    </div>
</div>
@section scripts{
    <script>
        $(function () {
            $(".partial-content").each(function (index, item) {
                var url = $(item).data("url");
                if (url && url.length > 0) {
                    $(item).load(url, function (response, status, xhr) {
                        if (status == 'success') {
                            $(this).removeAttr('hidden');
                        } else {
                            hxCore.ajaxError(xhr);
                            $(this).attr('hidden');
                        }
                    });
                }
            });
        });
        function login() {
            hxCore.ajax('', {
                data: {
                    returnUrl: window.location.href
                },
                success(data) {
                    alertify.genericDialog(data);
                }
            });
            
        }
    </script>
}
